package com.jindy.module.transferProduct.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.transferProduct.domain.SyTransferProductT;
import com.jindy.module.transferProduct.service.ISyTransferProductTService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 库存调拨产品Controller
 * 
 * @author jindy
 * @date 2023-04-12
 */
@RestController
@RequestMapping("/module/transferProduct")
public class SyTransferProductTController extends BaseController
{
    @Autowired
    private ISyTransferProductTService syTransferProductTService;

    /**
     * 查询库存调拨产品列表
     */
    @PreAuthorize("@ss.hasPermi('module:transferProduct:list')")
    @GetMapping("/list")
    public TableDataInfo list(SyTransferProductT syTransferProductT)
    {
        startPage();
        List<SyTransferProductT> list = syTransferProductTService.selectSyTransferProductTList(syTransferProductT);
        return getDataTable(list);
    }

    /**
     * 导出库存调拨产品列表
     */
    @PreAuthorize("@ss.hasPermi('module:transferProduct:export')")
    @Log(title = "库存调拨产品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SyTransferProductT syTransferProductT)
    {
        List<SyTransferProductT> list = syTransferProductTService.selectSyTransferProductTList(syTransferProductT);
        ExcelUtil<SyTransferProductT> util = new ExcelUtil<SyTransferProductT>(SyTransferProductT.class);
        util.exportExcel(response, list, "库存调拨产品数据");
    }

    /**
     * 获取库存调拨产品详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:transferProduct:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(syTransferProductTService.selectSyTransferProductTById(id));
    }

    /**
     * 新增库存调拨产品
     */
    @PreAuthorize("@ss.hasPermi('module:transferProduct:add')")
    @Log(title = "库存调拨产品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SyTransferProductT syTransferProductT)
    {
        return toAjax(syTransferProductTService.insertSyTransferProductT(syTransferProductT));
    }

    /**
     * 修改库存调拨产品
     */
    @PreAuthorize("@ss.hasPermi('module:transferProduct:edit')")
    @Log(title = "库存调拨产品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SyTransferProductT syTransferProductT)
    {
        return toAjax(syTransferProductTService.updateSyTransferProductT(syTransferProductT));
    }

    /**
     * 删除库存调拨产品
     */
    @PreAuthorize("@ss.hasPermi('module:transferProduct:remove')")
    @Log(title = "库存调拨产品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(syTransferProductTService.deleteSyTransferProductTByIds(ids));
    }
}
